

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=&#34;auto&#34;>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/2.jpg">
  <link rel="icon" type="image/png" href="/img/2.jpg">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="">
  <meta name="author" content="K">
  <meta name="keywords" content="">
  <title>docker-weave网络 - K</title>

  <link  rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.staticfile.org/github-markdown-css/4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/lib/hint/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/10.0.0/styles/github-gist.min.css" />
    
  

  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_kmeydafke9r.css">


<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 5.2.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/">&nbsp;<strong>かい</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;</a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" href="javascript:">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner intro-2" id="background" parallax=true
         style="background: url('/img/1.jpg') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="container page-header text-center fade-in-up">
            <span class="h2" id="subtitle">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2020-12-14 14:00" pubdate>
        2020年12月14日 下午
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      3.1k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      50
       分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="container nopadding-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto" id="post">
            <!-- SEO header -->
            <h1 style="display: none">docker-weave网络</h1>
            
            <div class="markdown-body" id="post-body">
              <h2 id="weave"><a href="#weave" class="headerlink" title="weave"></a>weave</h2><ul>
<li>weave网络属于第三方网络</li>
<li>weave在docker主机之间实现的是overlay网络，使用vxlan封装，基于udp传输，也可以加密传输</li>
<li>weave网络再开启时，会创建一个连接多个docker主机的虚拟网络，类似于以太网交换机，所有容器都连接在上面，互相通信</li>
</ul>
<h2 id="weave网络转发原理"><a href="#weave网络转发原理" class="headerlink" title="weave网络转发原理"></a>weave网络转发原理</h2><p><img src="/images/docker/weave.png" srcset="/img/loading.gif"></p>
<ul>
<li><p>在创建weave网络时，会在本机自动创建一个虚拟空间，这个空间里面有一个，datapath网卡功能类似于openvswitch交换机，和主机中的weave网卡</p>
</li>
<li><p>datapath中vxlan-6784和vethwe-datapath通过master桥接datapath的方式相连</p>
</li>
<li><p>weave中，容器通过veth_pair的方式和weave网卡相连，weave网卡通过vethwe-bridge网卡的veth_pair方式连接到vethwe-datapath中，vethwe-datapath和datapath已经通过master接口形式连接，再通过vxlan-6784将数据转发出主机到对端主机的datapath中</p>
</li>
<li><p>weave和datapath分工不同</p>
</li>
<li><p>weave负责将容器接入weave网络，datapath负责在主机建立vxlan隧道并收发数据</p>
</li>
<li><p>也就是说，容器发送数据会经过weave创建的虚拟空间，通过datapath将数据转发的到对端主机的网卡中，对端主机weave需要和本机是一个weave网络，同一个虚拟空间，才能实现通信</p>
</li>
</ul>
<h2 id="weave单主机通信"><a href="#weave单主机通信" class="headerlink" title="weave单主机通信"></a>weave单主机通信</h2><ul>
<li>安装weave网络<pre><code class="hljs gradle"># 下载weave
[root@localhost ~]# curl -L git.io<span class="hljs-regexp">/weave -o /u</span>sr<span class="hljs-regexp">/local/</span>bin/weave
# 给weave执行权限
[root@localhost ~]# chmod +x <span class="hljs-regexp">/usr/</span>local<span class="hljs-regexp">/bin/</span>weave</code></pre></li>
<li>启动weave网络<pre><code class="hljs routeros">[root@localhost ~]# weave launch
<span class="hljs-comment"># 下载完后查看网卡</span>
[root@localhost ~]# docker<span class="hljs-built_in"> network </span>ls
NETWORK ID          NAME                DRIVER              SCOPE
7fb6ebcd58bb       <span class="hljs-built_in"> bridge </span>            <span class="hljs-built_in"> bridge </span>             local
dc088ea51e19        host                host                local
cec68349a7d5        none                <span class="hljs-literal">null</span>                local
393257be6e00        weave               weavemesh           local
</code></pre>
<blockquote>
<p>会下载三个docker镜像</p>
</blockquote>
<pre><code class="hljs angelscript"><span class="hljs-string"> [root@localhost ~]</span># docker ps
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS               NAMES
<span class="hljs-number">6</span>caa8e9362ce        weaveworks/weave:<span class="hljs-number">2.7</span><span class="hljs-number">.0</span>   <span class="hljs-string">&quot;/home/weave/weaver …&quot;</span>   <span class="hljs-number">2</span> minutes ago       Up <span class="hljs-number">2</span> minutes                            weave

<span class="hljs-string">[root@localhost ~]</span># docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
weaveworks/weavedb     latest              c0b9094fe80b        <span class="hljs-number">4</span> months ago        <span class="hljs-number">698</span>B
weaveworks/weaveexec   <span class="hljs-number">2.7</span><span class="hljs-number">.0</span>               <span class="hljs-number">376</span>d0f04c22a        <span class="hljs-number">4</span> months ago        <span class="hljs-number">97.4</span>MB
weaveworks/weave       <span class="hljs-number">2.7</span><span class="hljs-number">.0</span>               <span class="hljs-number">2459</span>c1a2593f        <span class="hljs-number">4</span> months ago        <span class="hljs-number">82.6</span>MB
<span class="hljs-string">[root@localhost ~]</span># 

weave 是主程序 ，负责建立weave网络 提供dns服务等
weaveexec 是libnetwork CNM driver 实现docker网络
weavedb 提供docker命令代理服务，当用户使用weave集群中的docker创建容器时，它会自动将容器添加到weave网络</code></pre>
<blockquote>
<p>查看weave网卡的信息</p>
</blockquote>
<pre><code class="hljs routeros">[root@localhost ~]# docker<span class="hljs-built_in"> network </span>inspect weave 
<span class="hljs-string">&quot;Config&quot;</span>: [
                &#123;
                    <span class="hljs-string">&quot;Subnet&quot;</span>: <span class="hljs-string">&quot;10.32.0.0/12&quot;</span>
                &#125;
            ]
<span class="hljs-comment"># 默认网段为10.32.0.0/12</span></code></pre></li>
<li>让容器使用weave网络<pre><code class="hljs mel"># 执行以下命令，类似于进入一个网络的命名空间，在此模式下创建的容器将会默认使用weave网络的ip网段
[root@localhost ~]# <span class="hljs-keyword">eval</span> $(weave <span class="hljs-keyword">env</span>)</code></pre>
<blockquote>
<p>运行容器</p>
</blockquote>
<pre><code class="hljs angelscript"><span class="hljs-string"> [root@localhost ~]</span># docker run -itd --name bbox1 busybox
<span class="hljs-number">64382908</span>c9d7e9a8c691a78fa53719e0142d12fdfbd62110a6978cb9d7e83660
<span class="hljs-string">[root@localhost ~]</span># docker exec -it bbox1 ip a
<span class="hljs-number">1</span>: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu <span class="hljs-number">65536</span> qdisc noqueue qlen <span class="hljs-number">1000</span>
    link/loopback <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span> brd <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>
    inet <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>/<span class="hljs-number">8</span> scope host lo
       valid_lft forever preferred_lft forever
<span class="hljs-number">14</span>: <span class="hljs-symbol">eth0@</span>if15: &lt;BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue 
    link/ether <span class="hljs-number">02</span>:<span class="hljs-number">42</span>:ac:<span class="hljs-number">11</span>:<span class="hljs-number">00</span>:<span class="hljs-number">02</span> brd ff:ff:ff:ff:ff:ff
    inet <span class="hljs-number">172.17</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span>/<span class="hljs-number">16</span> brd <span class="hljs-number">172.17</span><span class="hljs-number">.255</span><span class="hljs-number">.255</span> scope global eth0
       valid_lft forever preferred_lft forever
<span class="hljs-number">16</span>: <span class="hljs-symbol">ethwe@</span>if17: &lt;BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN&gt; mtu <span class="hljs-number">1376</span> qdisc noqueue 
    link/ether <span class="hljs-number">86</span>:<span class="hljs-number">05</span>:<span class="hljs-number">49</span>:<span class="hljs-number">1</span>b:<span class="hljs-number">7</span>b:<span class="hljs-number">9</span>e brd ff:ff:ff:ff:ff:ff
    inet <span class="hljs-number">10.32</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>/<span class="hljs-number">12</span> brd <span class="hljs-number">10.47</span><span class="hljs-number">.255</span><span class="hljs-number">.255</span> scope global ethwe
       valid_lft forever preferred_lft forever
# 可以看到一共有两个网段的网卡，一个是用于和docker0网卡桥接，可以连接外网，一个是weave网络</code></pre></li>
<li>退出weave<pre><code class="hljs mel"># 执行该命令后，创建容器不会加入到weave网络了
[root@localhost ~]# <span class="hljs-keyword">eval</span> $(weave <span class="hljs-keyword">env</span> --restore)
</code></pre>

</li>
</ul>
<h2 id="weave网络分析"><a href="#weave网络分析" class="headerlink" title="weave网络分析"></a>weave网络分析</h2><ul>
<li>进入bbox1<pre><code class="hljs angelscript"><span class="hljs-string"> [root@localhost ~]</span># docker exec -it bbox1 sh
/ # ip a
<span class="hljs-number">1</span>: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu <span class="hljs-number">65536</span> qdisc noqueue qlen <span class="hljs-number">1000</span>
    link/loopback <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span> brd <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>
    inet <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>/<span class="hljs-number">8</span> scope host lo
       valid_lft forever preferred_lft forever
<span class="hljs-number">14</span>: <span class="hljs-symbol">eth0@</span>if15: &lt;BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue 
    link/ether <span class="hljs-number">02</span>:<span class="hljs-number">42</span>:ac:<span class="hljs-number">11</span>:<span class="hljs-number">00</span>:<span class="hljs-number">02</span> brd ff:ff:ff:ff:ff:ff
    inet <span class="hljs-number">172.17</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span>/<span class="hljs-number">16</span> brd <span class="hljs-number">172.17</span><span class="hljs-number">.255</span><span class="hljs-number">.255</span> scope global eth0
       valid_lft forever preferred_lft forever
<span class="hljs-number">16</span>: <span class="hljs-symbol">ethwe@</span>if17: &lt;BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN&gt; mtu <span class="hljs-number">1376</span> qdisc noqueue 
    link/ether <span class="hljs-number">86</span>:<span class="hljs-number">05</span>:<span class="hljs-number">49</span>:<span class="hljs-number">1</span>b:<span class="hljs-number">7</span>b:<span class="hljs-number">9</span>e brd ff:ff:ff:ff:ff:ff
    inet <span class="hljs-number">10.32</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>/<span class="hljs-number">12</span> brd <span class="hljs-number">10.47</span><span class="hljs-number">.255</span><span class="hljs-number">.255</span> scope global ethwe
       valid_lft forever preferred_lft forever
</code></pre>
<ul>
<li>这里ethwe16通过veth_pair连接到主机的17号网卡<pre><code class="hljs routeros">[root@localhost ~]#<span class="hljs-built_in"> ip </span>a
17: vethwepl69667@if16: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1376 qdisc noqueue master weave state UP<span class="hljs-built_in"> group default </span>
  link/ether ae:f0:40:e1:e9:fb brd ff:ff:ff:ff:ff:ff link-netnsid 0
  inet6 fe80::acf0:40ff:fee1:e9fb/64 scope link 
     valid_lft forever preferred_lft forever
</code></pre>
<blockquote>
<p>查看桥接网卡信息</p>
</blockquote>
<pre><code class="hljs routeros">  [root@localhost ~]# brctl show
bridge name    <span class="hljs-built_in"> bridge </span>id               STP enabled     interfaces
docker0         8000.02421ed6a0f7       <span class="hljs-literal">no</span>              veth212afa4
virbr0          8000.525400bb511b       <span class="hljs-literal">yes</span>             virbr0-nic
weave           8000.021a4a6a8971       <span class="hljs-literal">no</span>              vethwe-bridge
                                                        vethwepl69667</code></pre></li>
<li>主机中的17号网卡vethwepl69667桥接到了weave网卡中，而weave网卡还桥接了vethwe-bridge网卡，这个网卡也在主机中<pre><code class="hljs angelscript"><span class="hljs-number">12</span>: vethwe-<span class="hljs-symbol">bridge@</span>vethwe-datapath: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1376</span> qdisc noqueue master weave state UP group <span class="hljs-keyword">default</span> 
  link/ether <span class="hljs-number">62</span>:<span class="hljs-number">40</span>:<span class="hljs-number">29</span>:cc:<span class="hljs-number">50</span>:<span class="hljs-number">27</span> brd ff:ff:ff:ff:ff:ff
  inet6 fe80::<span class="hljs-number">6040</span>:<span class="hljs-number">29f</span>f:fecc:<span class="hljs-number">5027</span>/<span class="hljs-number">64</span> scope link 
     valid_lft forever preferred_lft forever
</code></pre></li>
<li>12号网卡通过veth_pair的方式连接到vethwe-datapath，而datapath通过master桥接接口的方式连接到了datapath网卡，而且vxlan-6784也连接着datapath<pre><code class="hljs routeros">13: vxlan-6784: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 65535 qdisc noqueue master datapath state UNKNOWN<span class="hljs-built_in"> group default </span>qlen 1000
  link/ether e2:d3:b4:28:26:2c brd ff:ff:ff:ff:ff:ff</code></pre>

</li>
</ul>
</li>
</ul>
<h2 id="weave跨主机通信"><a href="#weave跨主机通信" class="headerlink" title="weave跨主机通信"></a>weave跨主机通信</h2><ul>
<li>第一台主机创建好weave网络后</li>
<li>第二台主机加入到第一台主机的weave网络<blockquote>
<p>第二台主机安装好weave网络</p>
</blockquote>
<pre><code class="hljs mel"> # 启动weave网络时加入ip就可以加入对端主机的weave网络了
[root@localhost ~]# weave <span class="hljs-keyword">launch</span> <span class="hljs-number">192.168</span><span class="hljs-number">.100</span><span class="hljs-number">.211</span>

[root@localhost ~]# <span class="hljs-keyword">eval</span> $(weave <span class="hljs-keyword">env</span>)
</code></pre></li>
<li>启动容器<pre><code class="hljs angelscript"><span class="hljs-string">[root@localhost ~]</span># docker run -itd --name bbox2 busybox
<span class="hljs-number">5e4846</span>b1b2b51d91c5b42459eaec56e08ce6dddea070e2e69af888f7999004f7

<span class="hljs-string">[root@localhost ~]</span># docker exec -it bbox2 ip a
<span class="hljs-number">1</span>: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu <span class="hljs-number">65536</span> qdisc noqueue qlen <span class="hljs-number">1000</span>
    link/loopback <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span> brd <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>
    inet <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>/<span class="hljs-number">8</span> scope host lo
       valid_lft forever preferred_lft forever
<span class="hljs-number">16</span>: <span class="hljs-symbol">eth0@</span>if17: &lt;BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue 
    link/ether <span class="hljs-number">02</span>:<span class="hljs-number">42</span>:ac:<span class="hljs-number">11</span>:<span class="hljs-number">00</span>:<span class="hljs-number">02</span> brd ff:ff:ff:ff:ff:ff
    inet <span class="hljs-number">172.17</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span>/<span class="hljs-number">16</span> brd <span class="hljs-number">172.17</span><span class="hljs-number">.255</span><span class="hljs-number">.255</span> scope global eth0
       valid_lft forever preferred_lft forever
<span class="hljs-number">18</span>: <span class="hljs-symbol">ethwe@</span>if19: &lt;BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN&gt; mtu <span class="hljs-number">1376</span> qdisc noqueue 
    link/ether <span class="hljs-number">4</span>e:f3:<span class="hljs-number">7</span>b:<span class="hljs-number">73</span>:<span class="hljs-number">2f</span>:a8 brd ff:ff:ff:ff:ff:ff
    inet <span class="hljs-number">10.44</span><span class="hljs-number">.0</span><span class="hljs-number">.0</span>/<span class="hljs-number">12</span> brd <span class="hljs-number">10.47</span><span class="hljs-number">.255</span><span class="hljs-number">.255</span> scope global ethwe
       valid_lft forever preferred_lft forever
</code></pre></li>
<li>ping主机1的bbox1<pre><code class="hljs routeros"> [root@localhost ~]# docker exec -it bbox2<span class="hljs-built_in"> ping </span>bbox1
PING bbox1 (10.32.0.1): 56 data bytes
64 bytes <span class="hljs-keyword">from</span> 10.32.0.1: <span class="hljs-attribute">seq</span>=0 <span class="hljs-attribute">ttl</span>=64 <span class="hljs-attribute">time</span>=1.729 ms
64 bytes <span class="hljs-keyword">from</span> 10.32.0.1: <span class="hljs-attribute">seq</span>=1 <span class="hljs-attribute">ttl</span>=64 <span class="hljs-attribute">time</span>=0.509 ms
</code></pre>

</li>
</ul>
<h2 id="weave网络隔离（手动指定）"><a href="#weave网络隔离（手动指定）" class="headerlink" title="weave网络隔离（手动指定）"></a>weave网络隔离（手动指定）</h2><ul>
<li>指定地址参数WEAVE_CIDR<blockquote>
<p>指定网段：WEAVE_CIDR=net:10.10.0.0/24<br> 指定ip：WEAVE_CIDR=ip:10.10.10.10/24</p>
</blockquote>
</li>
</ul>
<h2 id="weave指定网段"><a href="#weave指定网段" class="headerlink" title="weave指定网段"></a>weave指定网段</h2><ul>
<li>指定网段不能超出10.32.0.0/12的范围<pre><code class="hljs angelscript"># 创建<span class="hljs-number">10.32</span><span class="hljs-number">.2</span><span class="hljs-number">.0</span>/<span class="hljs-number">24</span>网段
<span class="hljs-string">[root@localhost ~]</span># docker run --name bbox3 -itd -e WEAVE_CIDR=net:<span class="hljs-number">10.32</span><span class="hljs-number">.2</span><span class="hljs-number">.0</span>/<span class="hljs-number">24</span> busybox 
<span class="hljs-number">8545e4532631</span>d0b761d9d7945702223487687c97eb8d187979473bd75d4c6777

<span class="hljs-string">[root@localhost ~]</span># docker exec -it bbox3 sh
/ # ip a
<span class="hljs-number">1</span>: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu <span class="hljs-number">65536</span> qdisc noqueue qlen <span class="hljs-number">1000</span>
    link/loopback <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span> brd <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>
    inet <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>/<span class="hljs-number">8</span> scope host lo
       valid_lft forever preferred_lft forever
<span class="hljs-number">24</span>: <span class="hljs-symbol">eth0@</span>if25: &lt;BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue 
    link/ether <span class="hljs-number">02</span>:<span class="hljs-number">42</span>:ac:<span class="hljs-number">11</span>:<span class="hljs-number">00</span>:<span class="hljs-number">03</span> brd ff:ff:ff:ff:ff:ff
    inet <span class="hljs-number">172.17</span><span class="hljs-number">.0</span><span class="hljs-number">.3</span>/<span class="hljs-number">16</span> brd <span class="hljs-number">172.17</span><span class="hljs-number">.255</span><span class="hljs-number">.255</span> scope global eth0
       valid_lft forever preferred_lft forever
<span class="hljs-number">26</span>: <span class="hljs-symbol">ethwe@</span>if27: &lt;BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN&gt; mtu <span class="hljs-number">1376</span> qdisc noqueue 
    link/ether ca:<span class="hljs-number">55</span>:f1:<span class="hljs-number">3</span>e:<span class="hljs-number">83</span>:<span class="hljs-number">29</span> brd ff:ff:ff:ff:ff:ff
    inet <span class="hljs-number">10.32</span><span class="hljs-number">.2</span><span class="hljs-number">.128</span>/<span class="hljs-number">24</span> brd <span class="hljs-number">10.32</span><span class="hljs-number">.2</span><span class="hljs-number">.255</span> scope global ethwe
       valid_lft forever preferred_lft forever

# ping bbox2 试一下
/ # ping bbox2
PING bbox2 (<span class="hljs-number">10.44</span><span class="hljs-number">.0</span><span class="hljs-number">.0</span>): <span class="hljs-number">56</span> data bytes
# 通不了，因为不在一个网段了</code></pre>
<h2 id="weave指定ip"><a href="#weave指定ip" class="headerlink" title="weave指定ip"></a>weave指定ip</h2></li>
</ul>
<pre><code class="hljs angelscript"><span class="hljs-string">[root@localhost ~]</span># docker run -itd --name bbox5 -e WEAVE_CIDR=ip:<span class="hljs-number">10.32</span><span class="hljs-number">.6</span><span class="hljs-number">.6</span>/<span class="hljs-number">24</span> busybox
bce396bbd378a76538d506daf9c37800606e1fa8c07b64936bd154e8e76c36b4
<span class="hljs-string">[root@localhost ~]</span># docker exec -it bbox5 sh
/ # ip a
<span class="hljs-number">1</span>: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu <span class="hljs-number">65536</span> qdisc noqueue qlen <span class="hljs-number">1000</span>
    link/loopback <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span> brd <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>
    inet <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>/<span class="hljs-number">8</span> scope host lo
       valid_lft forever preferred_lft forever
<span class="hljs-number">28</span>: <span class="hljs-symbol">eth0@</span>if29: &lt;BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue 
    link/ether <span class="hljs-number">02</span>:<span class="hljs-number">42</span>:ac:<span class="hljs-number">11</span>:<span class="hljs-number">00</span>:<span class="hljs-number">04</span> brd ff:ff:ff:ff:ff:ff
    inet <span class="hljs-number">172.17</span><span class="hljs-number">.0</span><span class="hljs-number">.4</span>/<span class="hljs-number">16</span> brd <span class="hljs-number">172.17</span><span class="hljs-number">.255</span><span class="hljs-number">.255</span> scope global eth0
       valid_lft forever preferred_lft forever
<span class="hljs-number">30</span>: <span class="hljs-symbol">ethwe@</span>if31: &lt;BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN&gt; mtu <span class="hljs-number">1376</span> qdisc noqueue 
    link/ether d6:a5:<span class="hljs-number">9f</span>:ce:<span class="hljs-number">3</span>d:b5 brd ff:ff:ff:ff:ff:ff
    inet <span class="hljs-number">10.32</span><span class="hljs-number">.6</span><span class="hljs-number">.6</span>/<span class="hljs-number">24</span> brd <span class="hljs-number">10.32</span><span class="hljs-number">.6</span><span class="hljs-number">.255</span> scope global ethwe
       valid_lft forever preferred_lft forever</code></pre>

<h2 id="将主机加入weave网络"><a href="#将主机加入weave网络" class="headerlink" title="将主机加入weave网络"></a>将主机加入weave网络</h2><ul>
<li>前面的实验中，可能有的人回去尝试ping使用物理机去ping容器的weave网络的ip，实则是ping不同的，因为weave网络还没有网关</li>
</ul>
<ul>
<li>一般来说桥接卡都会有一个地址</li>
<li>但是weave 是一个私有的 VxLAN 网络，默认与外部网络隔离。<pre><code class="hljs routeros">[root@localhost ~]#<span class="hljs-built_in"> ip </span>a

8: weave: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1376 qdisc noqueue state UP<span class="hljs-built_in"> group default </span>qlen 1000
    link/ether 02:1a:4a:6a:89:71 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::1a:4aff:fe6a:8971/64 scope link 
       valid_lft forever preferred_lft forever
</code></pre>
<ul>
<li>要想外部网络访问到weave的容器的话</li>
<li>将主机加入到weave网络</li>
<li>把主机当做访问weave1的网关<pre><code class="hljs angelscript"># 给主机的 weave网络分配一个ip
<span class="hljs-string">[root@localhost ~]</span># weave expose
<span class="hljs-number">10.32</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span>
<span class="hljs-string">[root@localhost ~]</span># ip a
<span class="hljs-number">8</span>: weave: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1376</span> qdisc noqueue state UP group <span class="hljs-keyword">default</span> qlen <span class="hljs-number">1000</span>
    link/ether <span class="hljs-number">02</span>:<span class="hljs-number">1</span>a:<span class="hljs-number">4</span>a:<span class="hljs-number">6</span>a:<span class="hljs-number">89</span>:<span class="hljs-number">71</span> brd ff:ff:ff:ff:ff:ff
    inet <span class="hljs-number">10.32</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span>/<span class="hljs-number">12</span> brd <span class="hljs-number">10.47</span><span class="hljs-number">.255</span><span class="hljs-number">.255</span> scope global weave
       valid_lft forever preferred_lft forever
    inet6 fe80::<span class="hljs-number">1</span>a:<span class="hljs-number">4</span>aff:fe6a:<span class="hljs-number">8971</span>/<span class="hljs-number">64</span> scope link 
       valid_lft forever preferred_lft forever
</code></pre></li>
<li>这时候主机就会多出来一个路由条目<pre><code class="hljs angelscript"><span class="hljs-string"> [root@localhost ~]</span># ip r
<span class="hljs-number">10.32</span><span class="hljs-number">.0</span><span class="hljs-number">.0</span>/<span class="hljs-number">12</span> dev weave proto kernel scope link src <span class="hljs-number">10.32</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span> 

# 表示外部访问<span class="hljs-number">10.32</span><span class="hljs-number">.0</span><span class="hljs-number">.0</span>/<span class="hljs-number">12</span>网段中的地址时，由weave网卡<span class="hljs-number">10.32</span><span class="hljs-number">.0</span><span class="hljs-number">.3</span>作为网关来转发</code></pre>


</li>
</ul>
</li>
</ul>
<h2 id="指定weave网络的网段地址"><a href="#指定weave网络的网段地址" class="headerlink" title="指定weave网络的网段地址"></a>指定weave网络的网段地址</h2><p>启动服务后，默认会使用10.32.0.0/12地址段的所有网络，如果想去自定义网段，请执行weave launch –ipalloc-range x.x.x.x/xx即可</p>
<h2 id="weave跨网段通讯"><a href="#weave跨网段通讯" class="headerlink" title="weave跨网段通讯"></a>weave跨网段通讯</h2><ul>
<li><p>两台主机的weave网络没有相连</p>
</li>
<li><p>第一台主机 是 原地址 10.32.0.0/12地址</p>
</li>
<li><p>第二台主机 是 10.10.10.0/24地址</p>
<blockquote>
<p>主机1</p>
</blockquote>
<pre><code class="hljs angelscript"># 开启weave网络
<span class="hljs-string">[root@localhost ~]</span># weave launch
# 使创建的容器为weave网络中的容器
<span class="hljs-string">[root@localhost ~]</span># eval $(weave env)
# 创建容器
<span class="hljs-string">[root@localhost ~]</span># docker run -itd --name bbox1 busybox
<span class="hljs-number">8e8</span>e11712b1995e7d9f43900e19d988a9e46858ea95b3f906121a2218b5eb210
<span class="hljs-string">[root@localhost ~]</span># docker exec -it bbox1 ip a
<span class="hljs-number">1</span>: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu <span class="hljs-number">65536</span> qdisc noqueue qlen <span class="hljs-number">1000</span>
    link/loopback <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span> brd <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>
    inet <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>/<span class="hljs-number">8</span> scope host lo
       valid_lft forever preferred_lft forever
<span class="hljs-number">14</span>: <span class="hljs-symbol">eth0@</span>if15: &lt;BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue 
    link/ether <span class="hljs-number">02</span>:<span class="hljs-number">42</span>:ac:<span class="hljs-number">11</span>:<span class="hljs-number">00</span>:<span class="hljs-number">02</span> brd ff:ff:ff:ff:ff:ff
    inet <span class="hljs-number">172.17</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span>/<span class="hljs-number">16</span> brd <span class="hljs-number">172.17</span><span class="hljs-number">.255</span><span class="hljs-number">.255</span> scope global eth0
       valid_lft forever preferred_lft forever
<span class="hljs-number">16</span>: <span class="hljs-symbol">ethwe@</span>if17: &lt;BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN&gt; mtu <span class="hljs-number">1376</span> qdisc noqueue 
    link/ether <span class="hljs-number">16</span>:b1:<span class="hljs-number">9</span>c:c2:c2:a4 brd ff:ff:ff:ff:ff:ff
    inet <span class="hljs-number">10.32</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>/<span class="hljs-number">12</span> brd <span class="hljs-number">10.47</span><span class="hljs-number">.255</span><span class="hljs-number">.255</span> scope global ethwe
       valid_lft forever preferred_lft forever
</code></pre>
<blockquote>
<p>主机2</p>
</blockquote>
<pre><code class="hljs angelscript"> # 开启weave指定<span class="hljs-number">10</span>网段
<span class="hljs-string"> [root@localhost ~]</span># weave launch --ipalloc-range <span class="hljs-number">10.10</span><span class="hljs-number">.10</span><span class="hljs-number">.0</span>/<span class="hljs-number">24</span>
 # 使创建的容器为weave网络中的容器
<span class="hljs-string"> [root@localhost ~]</span># eval $(weave env)
 # 创建容器
<span class="hljs-string">[root@localhost ~]</span># docker run -itd --name bbox2 busybox
<span class="hljs-number">20</span>d198e78e7f897eefaf7b7e07889b8fc05c468230f1b889ac97e3dc79cab61b
<span class="hljs-string">[root@localhost ~]</span># docker exec -it bbox2 sh
/ # ip a
<span class="hljs-number">1</span>: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu <span class="hljs-number">65536</span> qdisc noqueue qlen <span class="hljs-number">1000</span>
    link/loopback <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span> brd <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>
    inet <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>/<span class="hljs-number">8</span> scope host lo
       valid_lft forever preferred_lft forever
<span class="hljs-number">14</span>: <span class="hljs-symbol">eth0@</span>if15: &lt;BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue 
    link/ether <span class="hljs-number">02</span>:<span class="hljs-number">42</span>:ac:<span class="hljs-number">11</span>:<span class="hljs-number">00</span>:<span class="hljs-number">02</span> brd ff:ff:ff:ff:ff:ff
    inet <span class="hljs-number">172.17</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span>/<span class="hljs-number">16</span> brd <span class="hljs-number">172.17</span><span class="hljs-number">.255</span><span class="hljs-number">.255</span> scope global eth0
       valid_lft forever preferred_lft forever
<span class="hljs-number">16</span>: <span class="hljs-symbol">ethwe@</span>if17: &lt;BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN&gt; mtu <span class="hljs-number">1376</span> qdisc noqueue 
    link/ether d6:c8:d0:<span class="hljs-number">6</span>d:<span class="hljs-number">6</span>b:<span class="hljs-number">59</span> brd ff:ff:ff:ff:ff:ff
    inet <span class="hljs-number">10.10</span><span class="hljs-number">.10</span><span class="hljs-number">.1</span>/<span class="hljs-number">24</span> brd <span class="hljs-number">10.10</span><span class="hljs-number">.10</span><span class="hljs-number">.255</span> scope global ethwe
       valid_lft forever preferred_lft forever</code></pre></li>
<li><p>两个容器是互相ping不通的</p>
<pre><code class="hljs routeros"> 10.10.10.1<span class="hljs-built_in"> ping </span>10.32.0.1
 / #<span class="hljs-built_in"> ping </span>10.32.0.1
PING 10.32.0.1 (10.32.0.1): 56 data bytes
</code></pre></li>
<li><p>要添加路由条目</p>
<blockquote>
<p>主机2</p>
</blockquote>
<pre><code class="hljs angelscript">
# 主机加入到weave网络
<span class="hljs-string">[root@localhost ~]</span># weave expose
<span class="hljs-number">10.10</span><span class="hljs-number">.10</span><span class="hljs-number">.2</span>
<span class="hljs-string">[root@localhost ~]</span># ip route add <span class="hljs-number">10.32</span><span class="hljs-number">.0</span><span class="hljs-number">.0</span>/<span class="hljs-number">12</span> via <span class="hljs-number">192.168</span><span class="hljs-number">.100</span><span class="hljs-number">.211</span> dev ens33
# 表示要访问 <span class="hljs-number">10.32</span><span class="hljs-number">.0</span><span class="hljs-number">.0</span>/<span class="hljs-number">12</span> 就要先经过 <span class="hljs-number">192.168</span><span class="hljs-number">.100</span><span class="hljs-number">.211</span> 的ens33网卡
# 因为这个网段地址在对端主机，所以要指向对端主机的ip
</code></pre>
<blockquote>
<p>主机1</p>
</blockquote>
<pre><code class="hljs angelscript"><span class="hljs-string">[root@localhost ~]</span># weave expose
<span class="hljs-number">10.32</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span>
<span class="hljs-string">[root@localhost ~]</span># ip route add <span class="hljs-number">10.10</span><span class="hljs-number">.10</span><span class="hljs-number">.0</span>/<span class="hljs-number">24</span> via <span class="hljs-number">192.168</span><span class="hljs-number">.100</span><span class="hljs-number">.212</span> dev ens33
# 表示要访问 <span class="hljs-number">10.10</span><span class="hljs-number">.10</span><span class="hljs-number">.0</span>/<span class="hljs-number">24</span> 就要先经过 <span class="hljs-number">102.168</span><span class="hljs-number">.100</span><span class="hljs-number">.212</span> 的 ens33
# 因为这个网段地址在对端主机，所以要指向对端主机的ip</code></pre>
</li>
<li><p>bbox2 ping bbox1</p>
<pre><code class="hljs routeros">[root@localhost ~]# docker exec -it bbox2 sh
/ #<span class="hljs-built_in"> ping </span>10.32.0.1
PING 10.32.0.1 (10.32.0.1): 56 data bytes
64 bytes <span class="hljs-keyword">from</span> 10.32.0.1: <span class="hljs-attribute">seq</span>=0 <span class="hljs-attribute">ttl</span>=62 <span class="hljs-attribute">time</span>=0.393 ms
64 bytes <span class="hljs-keyword">from</span> 10.32.0.1: <span class="hljs-attribute">seq</span>=1 <span class="hljs-attribute">ttl</span>=62 <span class="hljs-attribute">time</span>=0.385 ms
<span class="hljs-comment"># 可以ping通了</span></code></pre>
</li>
</ul>

            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/categories/docker/">docker</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/docker/">docker</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">本博客所有文章是以学习为目的，如果有不对的地方可以一起交流沟通共同学习 邮箱:1248287831@qq.com！</p>
              
              
                <div class="post-prevnext row">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2020/12/15/docker-%E7%9B%91%E6%8E%A7/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">docker-监控</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2020/12/11/docker-flannel%E7%BD%91%E7%BB%9C/">
                        <span class="hidden-mobile">docker-flannel</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div id="tocbot"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    
  </main>

  
    <a id="scroll-top-button" href="#" role="button">
      <i class="iconfont icon-arrowup" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://space.bilibili.com/39165374" target="_blank" rel="nofollow noopener"><span>LMK</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
  </div>
  
  <div class="statistics">
    
    

    
      
        <!-- 不蒜子统计PV -->
        <span id="busuanzi_container_site_pv" style="display: none">
            总访问量 
            <span id="busuanzi_value_site_pv"></span>
             次
          </span>
      
      
        <!-- 不蒜子统计UV -->
        <span id="busuanzi_container_site_uv" style="display: none">
            总访客数 
            <span id="busuanzi_value_site_uv"></span>
             人
          </span>
      
    
  </div>


  

  
</footer>

<!-- SCRIPTS -->
<script  src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
<script  src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js" ></script>
<script  src="/js/debouncer.js" ></script>
<script  src="/js/main.js" ></script>

<!-- Plugins -->


  
    <script  src="/js/lazyload.js" ></script>
  



  



  <script defer src="https://cdn.staticfile.org/clipboard.js/2.0.6/clipboard.min.js" ></script>
  <script  src="/js/clipboard-use.js" ></script>



  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





  <script  src="https://cdn.staticfile.org/tocbot/4.11.1/tocbot.min.js" ></script>
  <script>
    $(document).ready(function () {
      var boardCtn = $('#board-ctn');
      var boardTop = boardCtn.offset().top;

      tocbot.init({
        tocSelector: '#tocbot',
        contentSelector: '#post-body',
        headingSelector: 'h1,h2,h3,h4,h5,h6',
        linkClass: 'tocbot-link',
        activeLinkClass: 'tocbot-active-link',
        listClass: 'tocbot-list',
        isCollapsedClass: 'tocbot-is-collapsed',
        collapsibleClass: 'tocbot-is-collapsible',
        collapseDepth: 0,
        scrollSmooth: true,
        headingsOffset: -boardTop
      });
      if ($('.toc-list-item').length > 0) {
        $('#toc').css('visibility', 'visible');
      }
    });
  </script>



  <script  src="https://cdn.staticfile.org/typed.js/2.0.11/typed.min.js" ></script>
  <script>
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "docker-weave网络&nbsp;",
      ],
      cursorChar: "_",
      typeSpeed: 70,
      loop: false,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>



  <script  src="https://cdn.staticfile.org/anchor-js/4.2.2/anchor.min.js" ></script>
  <script>
    anchors.options = {
      placement: "right",
      visible: "hover",
      
    };
    var el = "h1,h2,h3,h4,h5,h6".split(",");
    var res = [];
    for (item of el) {
      res.push(".markdown-body > " + item)
    }
    anchors.add(res.join(", "))
  </script>



  <script  src="/js/local-search.js" ></script>
  <script>
    var path = "/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      searchFunc(path, 'local-search-input', 'local-search-result');
      this.onclick = null
    }
  </script>



  <script  src="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css" />

  <script>
    $('#post img:not(.no-zoom img, img[no-zoom]), img[zoom]').each(
      function () {
        var element = document.createElement('a');
        $(element).attr('data-fancybox', 'images');
        $(element).attr('href', $(this).attr('src'));
        $(this).wrap(element);
      }
    );
  </script>















</body>
</html>
